package com.hzqx.syndata.result1;
import com.alibaba.fastjson.JSONObject;


/**
 * Response返回结果类
 * @author yangxiaohui
 */
public class Result<T> {
    private Integer code;
    private String msg;
    private Object data;
    Result(){
        this.code=ResultEnum.SUCCESS.code();
        this.msg=ResultEnum.SUCCESS.msg();
        this.data=createNoneData();
    }
    Result(T data){
        this.code=ResultEnum.SUCCESS.code();
        this.msg=ResultEnum.SUCCESS.msg();
        this.data=data;
    }
    Result(ResultEnum resultEnum){
        this.code=resultEnum.code();
        this.msg=resultEnum.msg();
        this.data=createNoneData();
    }
    Result(ResultEnum resultEnum,T data){
        this.code=resultEnum.code();
        this.msg=resultEnum.msg();
        this.data=data;
    }
    /**
     * 创建一个空 {@link JSONObject} 对象
     * @return 空 {@link JSONObject} 对象
     */
    private static Object createNoneData(){
        return new JSONObject();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
